<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2018/12/6
  Time: 10:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link href="${pageContext.request.contextPath}/statics/hplus/css/bootstrap.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/statics/hplus/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/statics/hplus/js/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/hplus/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/hplus/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/hplus/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script>


        function searcha() {
            //返回表格的 Options。
            var opts = $("#roletb").bootstrapTable("getOptions") ;
            var limit = opts.pageSize ;
            var offset = (opts.pageNumber-1) * limit;
            var username = $("#username").val() ;
            $.post("${pageContext.request.contextPath}/RuKuTongJi/queryByNamechuku",{'id':username,'limit':limit,'offset':offset},function (data) {
                // var mydata = eval("("+data+")") ;
                //重新绑定表格数据
                $("#roletb").bootstrapTable('load',data) ;
            })
        }


        $(function () {
            $("#tapcanxq").bootstrapTable({
                url:"${pageContext.request.contextPath}/RuKuTongJi/querychukudanhao",
                //设置每页多少条数据
                pageSize:2,
                pageList:[2,4,8,16],
                height:300,
                pageNumber:1,
                //启用分页，但是默认情况下，是客户端分页的
                // pagination:true,
                // 启用服务器端分页
                //sidePagination:'server',
                columns:[
                    {
                        field:'chukushijian',
                        title:'入库时间'
                    },
                    {
                        field:'dianpu_Name',
                        title:'店铺'
                    },
                    {
                        field:'leixing_Name',
                        title:'操作类型'
                    },
                    {
                        field:'shangpin_Name',
                        title:'产品名称'
                    },
                    {
                        field:'shangpin_Shoujia',
                        title:'进价'
                    },
                    {
                        field:'shuliang',
                        title:'入库数量',
                        formatter: function(value,row,index){
                            return row.shuliang+"个";
                        },
                        //计算此列的值
                        footerFormatter: function(rows){
                            var zongshu = 0;
                            for (var i=0;i<rows.length;i++) {
                                zongshu += rows[i].shuliang
                            }
                            return zongshu+"个";
                        }
                    },
                    {
                        field:'jingbane_Name',
                        title:'经办员工'
                    },
                    {
                        field:'danhao',
                        title:'单号'
                    },
                    {
                        field:'beizhu',
                        title:'备注'
                    },

                ]
            }) ;
            $("#roletb").bootstrapTable({
                url:'${pageContext.request.contextPath}/RuKuTongJi/queryByNamechuku',
                //设置每页多少条数据
                pageSize:2,
                pageList:[2,4,8,16],
                height:300,
                pageNumber:1,
                showFooter:true,
                //启用分页，但是默认情况下，是客户端分页的
                pagination:true,
                //启用服务器端分页
                sidePagination:'server',
                queryParams:function(params){
                    var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                        limit: params.limit,  //页面大小
                        offset: params.offset, //页码
                        id:$("#username").val()
                    };
                    return temp;
                },
                columns:[
                    {
                        field:'rukushijian',
                        title:'入库时间',
                        footerFormatter: function(value){
                            return "总计：";
                        }
                    },
                    {
                        field:'dianpu_Name',
                        title:'店铺'
                    },
                    {
                        field:'leixing_Name',
                        title:'操作类型'
                    },
                    {
                        field:'jine',
                        title:'应付金额',
                        formatter: function(value,row,index){
                            return row.jine+"元";
                        },
                        //计算此列的值
                        footerFormatter: function(rows){
                            var zongjc = 0;
                            for (var i=0;i<rows.length;i++) {
                                zongjc += rows[i].jine
                            }

                            return zongjc+"元";
                        }

                    },
                    {
                        field:'jingbane_Name',
                        title:'经办员工'
                    },
                    {
                        field:'rukudanhao',
                        title:'单号'
                    },
                    {
                        field:'beizhu',
                        title:'备注信息'
                    },
                    {
                        field:'zhuangtai',
                        title:'状态'
                    },
                    {
                        title:'操作',
                        formatter:function(value,row,index){
                            var d=""+row.rukudanhao;
                            return "<button class='btn  btn-primary' onclick='query("+d+")'>查询单据</button>"+
                                "<button class='btn btn-primary' onclick='javascript:doxgai("+row.rukudanhao+")'>确认订单</button> &nbsp;"
                        }
                    },
                ]
            }) ;
        }) ;
        function query(danhao){
            $("#showtaocanxq").modal("show") ;
            $.post("${pageContext.request.contextPath}/RuKuTongJi/querychukudanhao",{'danhao':danhao},function (data) {
                // var mydata = eval("("+data+")") ;
                //重新绑定表格数据
                $("#tapcanxq").bootstrapTable('load',data) ;
            })








        }




        //根据修改编号
        var rukudanhao=0;

        //修改
        function doxgai(kid) {
            rukudanhao=kid;
        var zhuangtaiG=$("[name=zhuangtaiG]").val();
        $.post('${pageContext.request.contextPath}/RuKuTongJi/xiugai',{rukudanhao:rukudanhao,zhuangtai:zhuangtaiG},function (data) {
        if (data!=null){
        alert("成功")
        searcha();
        $("#Div4").modal('hide')
        } else {
        alert("失败")
        }
        })
        }


    </script>

</head>
<body>


<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">出库统计</h3>
    </div>



    <div class="panel-body">
        <div class="row">
            <div class="col-sm-6">
            </div>
            <div class="col-sm-6">
                <form  class="form-inline pull-right">
                    <input id="username" type="text" class="form-control">
                    <button class="btn btn-primary" onclick="searcha()" type="button"><span class="glyphicon glyphicon-search"></span>&nbsp;&nbsp;搜索</button>
                </form>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <table id="roletb"></table>
            </div>
        </div>
    </div>
</div>




<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" id="showtaocanxq">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-content animated bounceInRight">
                <table id="tapcanxq"></table>
                <div class="modal-footer">
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭<tton>
                </div>
            </div>
        </div>
    </div>
</div>

<%--<!--套餐详情模态框-->--%>
<%--<div class="modal inmodal" id="showtaocanxq">--%>
    <%--<div class="modal-dialog">--%>
        <%--<div class="modal-content animated bounceInRight">--%>
            <%--<table id="tapcanxq"></table>--%>
            <%--<div class="modal-footer">--%>
                <%--<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>--%>
            <%--</div>--%>
        <%--</div>--%>
    <%--</div>--%>
<%--</div>--%>




<div class="modal inmodal" id="Div4" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content animated bounceInRight">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">关闭</span>
                </button>
                <i class="fa fa-laptop modal-icon"></i>
                <h4 class="modal-title">审批</h4>
            </div>
            <form method="post" class="form-horizontal">
                <div class="modal-body">
                    <div class="ibox-content">

                        <div class="form-group" style="display:none">
                            <label class="col-sm-2 control-label">状态</label>
                            <div class="col-sm-10">
                                <input  name="zhuangtai" type="text" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">状态</label>
                            <div class="col-sm-10">
                                <input  name="zhuangtaiG" type="text" class="form-control">
                            </div>
                        </div>

                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" onclick="doxgai()">修改</button>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
</html>
